<?
if(!function_exists(pageft)){
	function pageft($totle,$displaypg=20,$url=''){
		global $page,$firstcount,$pagenav,$pagenav3,$show_page,$_SERVER;
		$GLOBALS["displaypg"]=$displaypg;
		
		$page=$_GET['page'];
		if(!$page){
			$page=1;
		}
		if(!$url){
			$url=$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
		}
		
		/* start by gong    at 2009-9-19 14:14 */
		$parse_url=parse_url($url);
		$url=str_replace("&page={$page}","",$url);
		$url=str_replace("page={$page}","",$url);
		$url=substr($url,strrpos($url,'/')+1,strlen($url)).'&page';
		/* end */

		$show_page=5;
		 
		$lastpg=ceil($totle/$displaypg);
		$page=min($lastpg,$page);
		$prepg=$page-1;
		$nextpg=($page==$lastpg ? 0 : $page+1);
		$firstcount=($page-1)*$displaypg;
		if($lastpg<=1) return false;
		

		$pagenav='';
		if($page>1){
			$pagenav.='<a href="'.$url.'='.$prepg.'" class="nav"><<</a>';
		}
		
 
		for($i=1;$i<=$page;$i++){
			if($i==$page){
				$pagenav.='<b><a class="navsel">'.$i.'</a></b>';
			}else{

				if($page-$i<$show_page){
					$pagenav.='<a href="'.$url.'='.$i.'" class="nav">'.$i.'</a>';
				}
			}
		}
		

		for($i=$page+1;$i<=$lastpg;$i++){
				if($page+$show_page-1>$i){
					$pagenav.='<a href="'.$url.'='.$i.'" class="nav">'.$i.'</a>';
				}
		}
		if($page<$lastpg){
			$pagenav.='<a href="'.$url.'='.$nextpg.'" class="nav">>></a>';
		}
 
		$pagenav3=$pagenav;
	}
}





/*
$total=mysql_num_rows($rs);
if($total>0){
	pageft($total,4);
	$rs=mysql_query($sql." limit $firstcount,$displaypg ");
    while($row=mysql_fetch_array($rs)){
	echo $row['login_ip'];
	echo "<hr>";
	}
}
*/
?>
